package edu.hawaii.duedates.tests;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertSame;
import static org.junit.Assert.fail;

import java.util.ArrayList;
import java.util.List;

//import org.junit.Ignore;
import org.junit.Test;

import edu.hawaii.duedates.BookInfoRecord;
import edu.hawaii.duedates.CommandLineArgs;
import edu.hawaii.duedates.HiStateLibrary;

/**
 * TestHslDueDates is a unit test to assure the user input for the HI state library 
 * is valid.  The test also checks getHawaiiStateInfo method responds to invalid entry.
 * 
 * @author Daniel Arakaki, John Ancheta, Mari-Lee Flestado
 * 
 * @version 1.0, October 31, 2008
 *
 */
public class TestHslDueDates {

  /**A String for the hsl option. */
  public static final String hsloption = "hsl";
  
  /**A statement used for an unexpected exception.*/
  private static final String FAILSTATEMENT = "Should not reach here...";
  
  /** Instance variable for hsl user id, instantiated to take in command argument. */
  private static final String hslId = null;

  /** Instance variable for hsl user last name, instantiated to take in command argument. */
  private static final String hslPassword = null;

  /** Instance variable for the arrayList bookList.*/
  private static List<BookInfoRecord> bookList = new ArrayList<BookInfoRecord>();
  
  /**
   * Tests for valid ID and last name with HI state library.
   * @throws Exception An exception is thrown when there is a problem with getHawaiiStateInfo.
   */
  @Test(expected = Exception.class)
  public void testGetHawaiiValidEntry() throws Exception {
    HiStateLibrary hiState = new HiStateLibrary();
    hiState.getHawaiiStateInfo(hslId, hslPassword, bookList);
    fail(FAILSTATEMENT);
  }
  
  /**
   * Tests for valid ID and invalid last name for HI state library.
   * 
   * @throws Exception An exception is thrown should a user not enter a last name.
   */
  @Test(expected = Exception.class)
  public void testHawaiiGetValidId() throws Exception {
    CommandLineArgs args = new CommandLineArgs();
    HiStateLibrary hiState = new HiStateLibrary();
    String sPassword = args.getHslLastFourDigitsForPhoneNumber();
    String hiPassword = "1234";
    
    hiState.getHawaiiStateInfo(hslId, hiPassword, bookList);
    assertSame("Testing password.", hiPassword, sPassword);
    assertEquals("Testing password length.", hiPassword.length(), sPassword.length());
  }
  
  /**
   * Tests for invalid ID and valid last name for HI state library.
   * 
   * @throws Exception An exception is thrown should a user not enter an ID.
   */
  @Test(expected = Exception.class)
  public void testHawaiiGetValidLastName() throws Exception {
    CommandLineArgs args = new CommandLineArgs();
    HiStateLibrary hiState = new HiStateLibrary();
    String sIdLength = args.getHslId();
    String anId = "1234567890";
    
    hiState.getHawaiiStateInfo(anId, hslPassword, bookList);
    assertSame("Testing id length.", sIdLength, anId.length());
    
  }
  
  /**
   * Tests for invalid ID and last name for HI state library.
   * 
   * @throws Exception An exception is thrown should a user not enter an ID or last name.
   */
  @Test(expected = Exception.class)
  public void testHiGetInvalidEntry() throws Exception {
    HiStateLibrary hiState = new HiStateLibrary();
    String id = null;
    String hiPassword = null;
    hiState.getHawaiiStateInfo(id, hiPassword, bookList);
    fail(FAILSTATEMENT);
  }
  
}
